using System;
using System.Collections.Generic;
using Blackbird.Core.Base;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace Blackbird.Core
{
    public delegate void ScreenClickEvent(object sender, ScreenMouseEventArgs e);

    public delegate void ScreenRenderableClickEvent(object sender, ScreenMouseEventArgs e);

    public delegate void ScreenMouseMotionEvent(object sender, ScreenMouseMotionEventArgs e);

    public delegate void ScreenMouseWheelEvent(object sender, ScreenMouseWheelEventArgs e);

    public delegate void ScreenUpdateEvent(object sender, ScreenUpdateEventArgs e);

    public delegate void ScreenRenderEvent(object sender, ScreenRenderEventArgs e);

    public delegate void ScreenKeypressEvent(object sender, ScreenKeypressEventArgs e);

    public delegate void ScreenRenderableCollisionEvent(object sender, ScreenRenderableCollisionEventArgs e);

    public class ScreenMouseEventArgs : EventArgs
    {
        private readonly List<Keys> _keys;
        private readonly MouseState _mouseState;

        public ScreenMouseEventArgs(MouseState mouseState, List<Keys> keys)
        {
            _mouseState = mouseState;
            _keys = keys;
        }

        public MouseState MouseState
        {
            get { return _mouseState; }
        }

        public List<Keys> Keys
        {
            get { return _keys; }
        }
    }

    public class ScreenMouseMotionEventArgs : ScreenMouseEventArgs
    {
        private readonly Vector2 _mouseDelta;

        public ScreenMouseMotionEventArgs(MouseState mouseState, List<Keys> keys, Vector2 mouseDelta)
            : base(mouseState, keys)
        {
            _mouseDelta = mouseDelta;
        }

        public Vector2 MouseDelta
        {
            get { return _mouseDelta; }
        }
    }

    public class ScreenRenderableClickEventArgs : ScreenMouseEventArgs
    {
        private readonly Vector2 _relativeMousePosition;

        public ScreenRenderableClickEventArgs(MouseState mouseState, List<Keys> keys, Vector2 relativeMousePosition)
            : base(mouseState, keys)
        {
            _relativeMousePosition = relativeMousePosition;
        }

        public Vector2 RelativeMousePosition
        {
            get { return _relativeMousePosition; }
        }
    }

    public class ScreenMouseWheelEventArgs : ScreenMouseEventArgs
    {
        private readonly int _wheelDelta;

        public ScreenMouseWheelEventArgs(MouseState mouseState, List<Keys> keys, int wheelDelta)
            : base(mouseState, keys)
        {
            _wheelDelta = wheelDelta;
        }

        public int WheelDelta
        {
            get { return _wheelDelta; }
        }
    }

    public class ScreenUpdateEventArgs : EventArgs
    {
        private readonly long _delta;

        public ScreenUpdateEventArgs(long delta)
        {
            _delta = delta;
        }

        public long Delta
        {
            get { return _delta; }
        }
    }

    public class ScreenRenderEventArgs : EventArgs
    {
        private readonly SpriteBatch _spriteBatch;

        public ScreenRenderEventArgs(SpriteBatch spriteBatch)
        {
            _spriteBatch = spriteBatch;
        }

        public SpriteBatch SpriteBatch
        {
            get { return _spriteBatch; }
        }
    }

    public class ScreenKeypressEventArgs : EventArgs
    {
        private readonly List<Keys> _keys;

        public ScreenKeypressEventArgs(List<Keys> keys)
        {
            _keys = keys;
        }

        public List<Keys> Keys
        {
            get { return _keys; }
        }
    }

    public class ScreenRenderableCollisionEventArgs : EventArgs
    {
        private readonly BaseRenderable _collider;

        public ScreenRenderableCollisionEventArgs(BaseRenderable collider)
        {
            _collider = collider;
        }

        public BaseRenderable Collider
        {
            get { return _collider; }
        }
    }
}